package com.bc.bczbweb.controller;

import com.bc.bcapi.service.StatisticsService;
import com.bc.bccore.util.PageHelper;
import com.bc.bcmodel.domain.T_CountryModel;
import com.bc.bcmodel.req.StatisticsReq;
import com.bc.bcmodel.resp.StatisticsListOrderResp;
import com.bc.bcmodel.resp.StatisticsListRechargeResp;
import com.bc.bcmodel.resp.StatisticsListWithdrawResp;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Name StatisticsController
 * @Description
 * @Author douhaichao
 * @Date 2018/9/26 14:38
 * @Version 1.0
 **/
@RestController
@RequestMapping(value = "statistics")
public class StatisticsController extends BaseController {

    @Autowired
    StatisticsService statisticsService;

    @RequestMapping("recharge/list")
    public ModelAndView rechargelist() {
        ModelAndView view = super.baseView("充值统计", "statistics/recharge/list");
        return view;
    }
    @RequestMapping("recharge/listdo")
    public ModelAndView rechargelistdo(StatisticsReq req) {
        ModelAndView view = super.baseViewAjax("充值统计", "statistics/recharge/listdo");
        PageInfo<StatisticsListRechargeResp> pageInfo = statisticsService.getRechargeList(req);
        StatisticsListRechargeResp total=statisticsService.getTotalRechargeList(req);
        view.addObject("data", pageInfo.getList());
        view.addObject("total",total);
        view.addObject("page", PageHelper.GetAjaxHtml(pageInfo, "javascript:loadpage(##);"));
        return view;
    }


    @RequestMapping("order/list")
    public ModelAndView orderlist() {
        ModelAndView view = super.baseView("订单统计", "statistics/order/list");
        return view;
    }
    @RequestMapping("order/listdo")
    public ModelAndView orderlistdo(StatisticsReq req) {
        ModelAndView view = super.baseViewAjax("订单统计", "statistics/order/listdo");
        PageInfo<StatisticsListOrderResp> pageInfo = statisticsService.getOrderList(req);
        StatisticsListOrderResp total=statisticsService.getTotalOrderList(req);
        view.addObject("data", pageInfo.getList());
        view.addObject("total",total);
        view.addObject("page", PageHelper.GetAjaxHtml(pageInfo, "javascript:loadpage(##);"));
        return view;
    }

    @RequestMapping("withdraw/list")
    public ModelAndView withdrawlist() {
        ModelAndView view = super.baseView("提现统计", "statistics/withdraw/list");
        return view;
    }
    @RequestMapping("withdraw/listdo")
    public ModelAndView withdrawlistdo(StatisticsReq req) {
        ModelAndView view = super.baseViewAjax("提现统计", "statistics/withdraw/listdo");
        PageInfo<StatisticsListWithdrawResp> pageInfo = statisticsService.getWithdrawList(req);
        StatisticsListWithdrawResp total=statisticsService.getTotalWithdrawList(req);
        view.addObject("data", pageInfo.getList());
        view.addObject("total",total);
        view.addObject("page", PageHelper.GetAjaxHtml(pageInfo, "javascript:loadpage(##);"));
        return view;
    }
}
